package com.youdianda.controller;

import com.youdianda.dto.YddAdvimgPageDTO;
import com.youdianda.entity.YddAdvimg;
import com.youdianda.result.Result;
import com.youdianda.service.YddAdvimgService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/ydd_advimg")
public class YddAdvimgController {
    @Autowired
    private YddAdvimgService yddAdvimgService;

    @GetMapping("/rowInfo")
    public Result rowInfo(Integer id) {
        Result rowInfo = yddAdvimgService.rowInfo(id);
        return Result.success(rowInfo);
    }
    @GetMapping("/list")
    public Result list(YddAdvimgPageDTO yddAdvimgPageDTO){
        return yddAdvimgService.list(yddAdvimgPageDTO);
   }

    @PostMapping("/update")
    public Result update(@RequestBody YddAdvimg yddAdvimg) {
        yddAdvimgService.updateAdvimg(yddAdvimg);
        return Result.success("ok");

    }

    @GetMapping("/del")
    public Result del(String id){
        yddAdvimgService.removeById(id);
        return Result.success();
    }
    @PostMapping("/add")
    public Result add(@RequestBody YddAdvimg yddAdvimg){
        yddAdvimgService.save(yddAdvimg);
        return Result.success();
    }
}
